package compilador.lexico;

import java.util.Enumeration;
import java.util.Hashtable;

public class TablaSimbolos {
	Hashtable<String,String> TS;
	Enumeration<String> e;
	
	public TablaSimbolos(){
		TS = new Hashtable<String, String>();
		e = null;    //e = TS.keys();
	}
	
	public void agregarSimbolo (String id, String valor){
		TS.put(valor, id);
	}
	
	public boolean contieneSimbolo(String valor){
		return (TS.containsKey(valor));
	}
	
	public boolean esPalabraReservada(String valor){
		if (valor.equals("if"))	return true;
		else if (valor.equals("else")) return true;
		else if (valor.equals("for")) return true;
		else if (valor.equals("print")) return true;
		else if (valor.equals("uint")) return true;
		else if (valor.equals("ulong")) return true;
		else return false;
	}

	public boolean hasMoreElement(){
		if (e == null) {
			e = TS.keys();
		}
		return e.hasMoreElements();
	}
	
	public String nextElement(){
		return (String) e.nextElement();
	}
	
	public String getId(String valor){
		return (String)TS.get(valor);
	}
}
